﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RenderEngine;
using System.Drawing;
using DeepZoomPivotConstructor.VisualLib;

namespace t_RenderEngine
{
    /// <summary>
    /// Summary description for t_LayoutHelper
    /// </summary>
    [TestClass]
    public class t_LayoutHelper
    {
        public t_LayoutHelper()
        {
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestSingleSlideLayout()
        {
            LayoutHelper h = new LayoutHelper();

            VisualBitmapImage bm = new VisualBitmapImage(1.0, 2.0, 100, Color.Black);
            Visual result = h.LayoutIn2By3Rows(new Visual[] { bm });

            Assert.AreEqual(1.0, result.Width, "Width is wrong");
            Assert.AreEqual(2.0, result.Height, "Height is wrong");
        }

        [TestMethod]
        public void TestTwoSlideLayout()
        {
            LayoutHelper h = new LayoutHelper();

            Visual result = h.LayoutIn2By3Rows(BuildList(2));

            Assert.AreEqual(2.0 + h.XBoarderSize, result.Width, "Width is wrong");
            Assert.AreEqual(2.0, result.Height, "Height is wrong");
        }

        [TestMethod]
        public void TestThreeSlideLayout()
        {
            LayoutHelper h = new LayoutHelper();

            Visual result = h.LayoutIn2By3Rows(BuildList(3));

            Assert.AreEqual(3.0 + 2.0*h.XBoarderSize, result.Width, "Width is wrong");
            Assert.AreEqual(2.0, result.Height, "Height is wrong");
        }

        [TestMethod]
        public void TestFourSlideLayout()
        {
            LayoutHelper h = new LayoutHelper();

            Visual result = h.LayoutIn2By3Rows(BuildList(4));

            Assert.AreEqual(2.0 + h.XBoarderSize, result.Width, "Width is wrong");
            Assert.AreEqual(4.0 + h.YBoarderSize, result.Height, "Height is wrong");
        }

        [TestMethod]
        public void TestFiveSlideLayout()
        {
            LayoutHelper h = new LayoutHelper();

            Visual result = h.LayoutIn2By3Rows(BuildList(5));

            Assert.AreEqual(3.0 + 2.0*h.XBoarderSize, result.Width, "Width is wrong");
            Assert.AreEqual(4.0 + h.YBoarderSize, result.Height, "Height is wrong");
        }

        private Visual[] BuildList(int n)
        {
            Visual[] result = new Visual[n];

            for (int i = 0; i < n; i++)
            {
                result[i] = new VisualBitmapImage(1.0, 2.0, 100, Color.Black); 
            }

            return result;
        }
    }
}
